package com.power.controller;

import com.alibaba.fastjson.JSON;
import com.power.ov.ResultDataTable;
import com.power.service.TowerService;
import com.power.service.impl.TowerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 李辽
 * Date: 2020/10/05 20:02
 * Description:根据所属线路和杆塔状态查询杆塔信息
 * Version: V1.0
 */
@WebServlet("/SearchTower.do")
public class SearchTower extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int  page = Integer.parseInt(request.getParameter("page"));
        int  limit = Integer.parseInt(request.getParameter("limit"));

        String line_number = request.getParameter("line_number");
        int tower_state = Integer.parseInt(request.getParameter("tower_state"));


        response.setContentType("application/json;charset=utf-8");
        TowerService towerService = new TowerServiceImpl();
        ResultDataTable resultDataTable  = null;

        try {
            resultDataTable = towerService.SearchTower(page,limit,line_number,tower_state);
            response.getWriter().write(JSON.toJSONString(resultDataTable));
            response.getWriter().flush();
            response.getWriter().close();
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }


}

















